This sample Commentary plugin returns HTML content. It retrieves the HTML content from a DERBY database, using the target.
The Commentary plugin in this example does the following:
The sample code will cover the following:
This sample code needs the following to run:
Parents and Children rulebase (examples\rulebases\compiled\Parents and Children.zip)
The DERBY SQL database is created by using create_db.sql which is located in examples\interview-engine\derby-commentary\src.
The 'COMMENT_LOCATION' column contains the ID of the 'target' to match.
The 'COMMENT_CONTENT" column contains the HTML commentary content for the 'target'.
Commentary |
---|
COMMENT_ID |
COMMENT_LOCATION |
COMMENT_CONTENT |
Copy the DERBY libraries to the library folder in Web Determinations (for example, <webroot>\WEB-INF\lib)
Ensure that DERBY is run in network server mode
Once registered, Web Determinations will call DerbyCommentary.isCommentaryEnabled() when a screen is to be displayed; the DerbyCommentary plugin always returns true.
When a screen is to be displayed, Web Determinations calls DerbyCommentary.hasCommentary() method for the screen itself, to check if commentary information exists for the screen. The same method is also called for each attribute control to be displayed in the screen. DerbyCommentary.hasCommentary() uses the target to query DERBY database and check if commentary data is available for the target screen/attribute.
If DerbyCommentary.hasCommentary() returns true for a target, its label is rendered as a link.
When the user clicks on the label link, Web Determinations calls DerbyCommentary.isCommentaryRedirect() to check if the commentary for the target (the clicked label link) returns URL or HTML content; the DerbyCommentary plugin always returns false, since it can only provide commentary in HTML content.
Web Determinations then calls DerbyCommentary.getCommentaryContent() to get the HTML commentary content for the target. DerbyCommentary queries the DERBY database and retrieves the commentary for the target. As mentioned before, the DERBY database has stored the commentary in pure HTML format, so DerbyCommentary does not need to process the data from DERBY database into HTML. DerbyCommentary encapsulates the HTML string in a TypedInputStream, and returns it to Web Determinations for display. A sequence similar to the above, can be found in Commentary Plugin
To view the source code for the DerbyCommentary sample, refer to examples\interview-engine\derby-commentary in the Java runtime zip file.